package com.zhkj.txg.module.member.ui

import android.view.View
import androidx.lifecycle.Observer
import com.zhkj.lib.base.ViewModelActivity
import com.zhkj.lib.http.HttpResponseStatus
import com.zhkj.lib.utils.SpanUtil
import com.zhkj.txg.R
import com.zhkj.txg.module.member.vm.MemberCardViewModel
import kotlinx.android.synthetic.main.activity_member_total_income.*

class TotalIncomeActivity : ViewModelActivity<MemberCardViewModel>() {
    override fun setViewModel(): MemberCardViewModel = createViewModel()
    override fun statusTitleBar(): View? = titleTotalIncome
    override val layoutResId: Int = R.layout.activity_member_total_income

    override fun initViewModel() {
        viewModel.totalIncomeLiveData.observe(this, Observer { response ->
            handlerResponseStatus(response.status, response.statusTip)
            if (response.status == HttpResponseStatus.Status.SUCCESS) response.response?.data?.let {
                tvTotalIncome.text = SpanUtil.setMoneySymbol(it.total)
                tvIncomeCanWithdraw.text = SpanUtil.setMoneySymbol(it.withdraw.toString())
                tvIncomeNotWithdraw.text = SpanUtil.setMoneySymbol(it.willGain.toString())
            }
        })
    }

    override fun initData() {
        viewModel.totalIncome()
    }
}